package com.greatwqs.wmall.user.provider.model.po;

import java.util.Date;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * Created by MyBatis Generator 2025/04/01
 * https://github.com/greatwqs/mybatis-generator-plugin
 */
@Getter
@Setter
@ToString
public class UserLogin {
    private Long seq;

    private Long userId;

    private String loginToken;

    private Date expireTime;

    private Boolean valid;

    private Date createTime;

    private Date updateTime;

    /**
     * need refresh expire time?
     */
    public boolean needRefreshExpireTime() {
        /***
         * 用户通过token访问api时， 应该同步更新过期+2小时。
         * 为了不影响数据库的更新性能，60秒更新一次
         */
        final long overtimeMs = 1000L * 60;
        return updateTime != null && System.currentTimeMillis() - updateTime.getTime() >= overtimeMs;
    }
}